package com.ruoyi.web.controller.datastatistics;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.datastatistics.domain.RealtimegatherdataXb;
import com.ruoyi.datastatistics.service.IRealtimegatherdataXbService;
import com.ruoyi.datastatistics.vo.XbDatabaseVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 实时数据采集（小）Controller
 *
 * @author ruoyi
 * @date 2023-09-07
 */
@RestController
@RequestMapping("/datastatistics/realtimegatherdataxb")
public class RealtimegatherdataXbController extends BaseController
{
    @Autowired
    private IRealtimegatherdataXbService realtimegatherdataXbService;

    /**
     * 查询实时数据采集（小）列表
     */
    @PreAuthorize("@ss.hasPermi('datastatistics:realtimegatherdataxb:list')")
    @GetMapping("/list")
    public TableDataInfo list(RealtimegatherdataXb realtimegatherdataXb)
    {
        startPage();
        List<RealtimegatherdataXb> list = realtimegatherdataXbService.selectList(realtimegatherdataXb);
        return getDataTable(list);
    }

    /**
     * 导出实时数据采集（小）列表
     */
    @PreAuthorize("@ss.hasPermi('datastatistics:realtimegatherdataxb:export')")
    @Log(title = "实时数据采集（小）", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RealtimegatherdataXb realtimegatherdataXb)
    {
        List<RealtimegatherdataXb> list = realtimegatherdataXbService.selectList(realtimegatherdataXb);
        ExcelUtil<RealtimegatherdataXb> util = new ExcelUtil<RealtimegatherdataXb>(RealtimegatherdataXb.class);
        util.exportExcel(response, list, "实时数据采集（小）数据");
    }

    /**
     * 获取实时数据采集（小）详细信息
     */
    @PreAuthorize("@ss.hasPermi('datastatistics:realtimegatherdataxb:query')")
    @GetMapping(value = "/{TerminalID}")
    public AjaxResult getInfo(@PathVariable("TerminalID") String TerminalID)
    {
        return success(realtimegatherdataXbService.selectRealtimegatherdataXbByTerminalID(TerminalID));
    }

    /**
     * 新增实时数据采集（小）
     */
    @PreAuthorize("@ss.hasPermi('datastatistics:realtimegatherdataxb:add')")
    @Log(title = "实时数据采集（小）", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RealtimegatherdataXb realtimegatherdataXb)
    {
        return toAjax(realtimegatherdataXbService.insertRealtimegatherdataXb(realtimegatherdataXb));
    }

    /**
     * 修改实时数据采集（小）
     */
    @PreAuthorize("@ss.hasPermi('datastatistics:realtimegatherdataxb:edit')")
    @Log(title = "实时数据采集（小）", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RealtimegatherdataXb realtimegatherdataXb)
    {
        return toAjax(realtimegatherdataXbService.updateRealtimegatherdataXb(realtimegatherdataXb));
    }

    /**
     * 删除实时数据采集（小）
     */
    @PreAuthorize("@ss.hasPermi('datastatistics:realtimegatherdataxb:remove')")
    @Log(title = "实时数据采集（小）", businessType = BusinessType.DELETE)
	@DeleteMapping("/{TerminalIDs}")
    public AjaxResult remove(@PathVariable String[] TerminalIDs)
    {
        return toAjax(realtimegatherdataXbService.deleteRealtimegatherdataXbByTerminalIDs(TerminalIDs));
    }
}
